using System;
using System.Windows;
using System.Windows.Media;
using Microsoft.Practices.ObjectBuilder;
using SCSFContrib.CompositeUI.WPF.Workspaces;
using SCSF=SCSFContrib.CompositeUI.WPF.Workspaces;

namespace WindowWorkspace
{
	public partial class MainWindow
	{
		private readonly RootWorkItem _workItem;
		private readonly SCSF.WindowWorkspace _windowWorkspace;

		public MainWindow([Dependency] RootWorkItem workItem, [Dependency] SCSF.WindowWorkspace windowWorkspace)
		{
			InitializeComponent();
			_workItem = workItem;
			_windowWorkspace = windowWorkspace;
		}

		private void _default_Click(object sender, EventArgs e)
		{
			ShowWindow(new WindowSmartPartInfo());
		}

		private void _title_Click(object sender, EventArgs e)
		{
			ShowWindow(new WindowSmartPartInfo("Here is the customized window title"));
		}

		private void _modal_Click(object sender, EventArgs e)
		{
			WindowSmartPartInfo smartPartInfo = new WindowSmartPartInfo();
			smartPartInfo.IsModal = true;
			ShowWindow(smartPartInfo);
		}

		private void _size_Click(object sender, EventArgs e)
		{
			WindowSmartPartInfo smartPartInfo = new WindowSmartPartInfo();
			smartPartInfo.Width = 200;
			smartPartInfo.Height = 200;
			smartPartInfo.MinWidth = 150;
			smartPartInfo.MinHeight = 150;
			smartPartInfo.MaxWidth = 250;
			smartPartInfo.MaxHeight = 250;
			smartPartInfo.ResizeMode = ResizeMode.CanResizeWithGrip;
			ShowWindow(smartPartInfo);
		}

		private void _style_Click(object sender, EventArgs e)
		{
			//we'll create the style here, but you just as easily define it in XAML and look it up
			Style style = new Style();
			style.Setters.Add(new Setter(Window.BackgroundProperty, new SolidColorBrush(Colors.Aqua)));

			WindowSmartPartInfo smartPartInfo = new WindowSmartPartInfo();
			smartPartInfo.WpfStyle = style;
			ShowWindow(smartPartInfo);
		}
		
		private void ShowWindow(WindowSmartPartInfo smartPartInfo)
		{
			Child child = _workItem.SmartParts.AddNew<Child>();
			_windowWorkspace.Show(child, smartPartInfo);
		}
	}
}